
Public Class Appearance

    Protected _appearance_id As Integer
    Protected _appearance_name_tha As String
    Protected _appearance_name_eng As String
    Protected _Data As ArrayList
    Protected _DataCurrent As Integer

    Public Property appearance_id() As Integer
        Get
            Return _appearance_id
        End Get
        Set(ByVal value As Integer)
            _appearance_id = value
        End Set
    End Property

    Public Property appearance_name_tha() As String
        Get
            Return _appearance_name_tha
        End Get
        Set(ByVal value As String)
            _appearance_name_tha = value
        End Set
    End Property

    Public Property appearance_name_eng() As String
        Get
            Return _appearance_name_eng
        End Get
        Set(ByVal value As String)
            _appearance_name_eng = value
        End Set
    End Property

    Public Function getAppearance() As System.Data.DataSet
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_Appearance"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "Appearance")

        Return objDs
    End Function

    Protected Function getsAppearance() As ArrayList
        Dim outResult As New ArrayList()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_Appearance"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "Appearance")

        For Each objDr As System.Data.DataRow In objDs.Tables("Appearance").Rows
            Dim obj As Appearance = New Appearance
            obj.appearance_id = objDr.Item("appearance_id").ToString()
            obj.appearance_name_tha = objDr.Item("appearance_name_tha").ToString()
            obj.appearance_name_eng = objDr.Item("appearance_name_eng").ToString()
            outResult.Add(obj)
        Next

        Return outResult
    End Function

    Public Function NextRecord() As Boolean
        If ((Not _Data Is Nothing) AndAlso (((Not _Data Is Nothing) AndAlso _
            (_DataCurrent < _Data.Count And _Data.Count > 0)))) Then
            _appearance_id = _Data(_DataCurrent).appearance_id
            _appearance_name_tha = _Data(_DataCurrent).appearance_name_tha
            _appearance_name_eng = _Data(_DataCurrent).appearance_name_eng
            _DataCurrent += 1
            Return True
        End If
        Return False
    End Function

    Public Sub LoadAppearance()
        _Data = New ArrayList
        _DataCurrent = 0
        _Data = getsAppearance()
    End Sub

    Public Function getAppearanceByNameEng(ByVal inAppearanceNameEng As String) As Appearance
        Dim outResult As New Appearance()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_AppearanceByNameEng"

        Dim objParam As New MySql.Data.MySqlClient.MySqlParameter("inAppearanceNameEng", inAppearanceNameEng)
        objCmd.Parameters.Add(objParam)

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "Appearance")

        For Each objDr As System.Data.DataRow In objDs.Tables("Appearance").Rows
            outResult.appearance_id = objDr.Item("appearance_id").ToString()
            outResult.appearance_name_tha = objDr.Item("appearance_name_tha").ToString()
            outResult.appearance_name_eng = objDr.Item("appearance_name_eng").ToString()
        Next

        Return outResult
    End Function

End Class
